<?php
global $sys;
$userObj = new Model_User();
if ($_SESSION['user']['id']!="") {
	$user = $userObj->getItemById($_SESSION['user']['id']);
}
?>
<h2>Register</h2>
<script type="text/javascript">
jQuery(document).ready(function(){
	jQuery('#pwd').val("");
	jQuery('#cpwd').val("");
	
	jQuery('#submit').click(function(){
		if ((jQuery('#pwd').val()==jQuery('#cpwd').val())) {
			return true;
		} else if (jQuery('#pwd').val()!="") {
			alert("passwords are not matching.");
			return false;
		}
	});
});
</script>
<form action="<?php echo HOST_URL; ?>profile/register" method="post">
<?php $sys->formToken(); ?>
<style>
.content table,.content table th, .content table td{
	border:none;
	border-right: none;
}
</style>
<div class="content-box box">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table-wrap">
  <tr>
    <td width="32%" align="left" valign="middle"><p class="nomt"><strong>First Name:</strong></p></td>
    <td width="68%" align="left" valign="middle"><span id="sprytextfield1">
          <input type="text" size="65" class="input" name="post[user_fname]" value="<?php echo $user['user_fname']; ?>" /><br/>
        <span class="textfieldRequiredMsg">A value is required.</span></span></td>
  </tr>
  <tr>
    <td align="left" valign="middle"><p class="nomt"><strong>Last Name:</strong></p></td>
    <td align="left" valign="middle"><span id="sprytextfield2">
          <input type="text" size="65" class="input" name="post[user_lname]" value="<?php echo $user['user_lname']; ?>" /><br/>
        <span class="textfieldRequiredMsg">A value is required.</span></span></td>
  </tr>
  <tr>
    <td align="left" valign="middle"><p><strong>Your E-mail:</strong></p></td>
    <td align="left" valign="middle"><span id="sprytextfield4">
        <input type="text" size="65" class="input" name="post[user_mail]" value="<?php echo $user['user_mail']; ?>" <?php if ($_SESSION['user']['id']!="") { ?>readonly="readonly" disabled="disabled"<?php } ?> /><br/>
        <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
  </tr>
  <tr>
    <td align="left" valign="middle"><p><strong>Password:</strong></p></td>
    <td align="left" valign="middle">
    <?php if ($_SESSION['user']['id']=="") { ?><span id="sprypassword1"><?php } ?>
      <input type="password" size="65" class="input" name="pwd" id="pwd" value="" /><br/>
      <?php if ($_SESSION['user']['id']=="") { ?><span class="passwordRequiredMsg">A value is required.</span><span class="passwordInvalidStrengthMsg">The password doesn't meet the specified strength use number and special charectors also.</span><span class="passwordMinCharsMsg">Minimum 7 characters needed.</span></span><?php } ?></td>
  </tr>
  <tr>
    <td align="left" valign="middle"><p><strong>Confirm Password:</strong></p></td>
    <td align="left" valign="middle"><input type="password" size="65" class="input" name="cpwd" id="cpwd" value="" /></td>
  </tr>
  <tr>
    <td align="left" valign="middle"><p>Your Telephone Number:</p></td>
    <td align="left" valign="middle"><input type="text" size="65" class="input" name="post[user_phone]" value="<?php echo $user['user_phone']; ?>" /></td>
  </tr>
  <tr>
    <td align="left" valign="middle">&nbsp;</td>
    <td align="left" valign="middle"><p class="nomb t-center"><input type="image" src="<?php echo THEME_URL; ?>design/btn-ok.gif" value="OK" id="submit" /></p></td>
  </tr>
</table>
</div><!-- /content-box -->
</form>

<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "email");
<?php if ($_SESSION['user']['id']=="") { ?>
var sprypassword1 = new Spry.Widget.ValidationPassword("sprypassword1", {minAlphaChars:0, minNumbers:0, minChars:5, minSpecialChars:0});
<?php } ?>
</script>
